package com.ruoyi.controller;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.service.MaterielThreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@RestController
@RequestMapping("/materielThree")
public class MaterielThreeController {
    @Autowired
    private MaterielThreeService materielThreeService;

    //查询物料物信息
    @GetMapping("/select")
    public R select(int page, int limit, String itemCode, String lotCode, String supplierName, String docDate) throws IOException {
        if ((itemCode != null && !itemCode.isEmpty())||
                (lotCode != null && !lotCode.isEmpty() )||
                (supplierName != null && !supplierName.isEmpty())||
                (docDate != null && !docDate.isEmpty())){
            return R.ok(materielThreeService.selectMaterielThree(page,limit,itemCode,lotCode,supplierName,docDate));
        }else{
            return R.ok(materielThreeService.allMaterielThree(page,limit));
        }
    }

  /*  @PostMapping( "/createMaterielThree")
    public R createMaterielThree(@RequestParam("supplierCode")String supplierCode,
                         @RequestParam("itemCode")String itemCode,
                         @RequestParam("itemDescription")String itemDescription,
                         @RequestParam("itemSpecification")String itemSpecification,
                         @RequestParam("lotCode")String lotCode,
                         @RequestParam("remark")Integer remark,
                         @RequestParam("businessQty")Double businessQty,
                         @RequestParam("arrivalDate")String arrivalDate
                        )  {

        // 将字符串转换为JSON
        JSONObject jsonContent = new JSONObject();
        jsonContent.put("supplierCode",supplierCode);
        jsonContent.put("itemCode", itemCode);
        jsonContent.put("itemDescription", itemDescription);
        jsonContent.put("itemSpecification", itemSpecification);
        jsonContent.put("lotCode",lotCode);
        jsonContent.put("remark",remark);
        //jsonContent.put("pieces", pieces);
        jsonContent.put("businessQty", businessQty);
        jsonContent.put("arrivalDate", arrivalDate);
        return R.ok(jsonContent);

    }*/

}

